home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1996 February / EnigmA AMIGA RUN 04 (1996)(G.R. Edizioni)(IT)[!][issue 1996-02][Skylink CD III].iso / earcd / program / ros_v1_2.lha / NonSystemStartupROS.S next >
Text File  |  1996-01-08  |  10KB  |  506 lines

  1. **
  2. **    $VER: NonSystemStartup.S 4.2 (08.01.96)
  3. **
  4. **    NonSystemStartup-Routine for Intros/Demos
  5. **    Needs RETIRE-Operating-System Includes & Library
  6. **    ASM-One V1.09 or later required
  7. **
  8. **    RETIRE Operating System (ROS) programmed by TIK/RETIRE
  9. **    Useful ideas and hints by TODI/RETIRE
  10. **    Thanks to PABLO/RETIRE for ROS beta testing
  11. **
  12. **    ROS included by TODI/RETIRE
  13. **
  14. **    Features: - ROSAddTimerInt
  15. **          - ROSAllocAudio
  16. **          - ROSAllocMem
  17. **          - ROSAwakeSystem
  18. **          - ROSChipsetCheck
  19. **          - ROSCPUCheck
  20. **          - ROSCPUClock
  21. **          - ROSDeleteFile
  22. **          - ROSDisableReq
  23. **          - ROSEnableReq
  24. **          - ROSFreeAudio
  25. **          - ROSFreeMem
  26. **          - ROSGetDMA
  27. **          - ROSGetInt
  28. **          - ROSGetKey
  29. **          - ROSKillSystem
  30. **          - ROSQueryKeys
  31. **          - ROSReadExe
  32. **          - ROSReadFile
  33. **          - ROSRemTimerInt
  34. **          - ROSRequester
  35. **          - ROSScreenToBack
  36. **          - ROSScreenToFront
  37. **          - ROSSetCache
  38. **          - ROSSetCopper
  39. **          - ROSSetDMA
  40. **          - ROSSetExitHandler
  41. **          - ROSSetInt
  42. **          - ROSSetIntVec
  43. **          - ROSSetTimerVec
  44. **          - ROSStartTimer
  45. **          - ROSStopTimer
  46. **          - ROSSysCall
  47. **          - ROSSysCallEnd
  48. **          - ROSWaitVBlank
  49. **          - ROSWriteFile
  50.  
  51.  
  52. *------------------------------------------------------------------------------
  53.  
  54.     INCDIR    Include:
  55.  
  56.     INCLUDE    Exec/exec_lib.i
  57. ;    INCLUDE    Exec/memory.i
  58. ;    INCLUDE    Hardware/custom.i
  59. ;    INCLUDE    Hardware/cia.i
  60.     INCLUDE    intuition/intuition_lib.i
  61.     INCLUDE    Libraries/ros.i
  62.     INCLUDE    Libraries/ros_lib.i
  63.  
  64. *------------------------------------------------------------------------------
  65.  
  66. SourceTest    = 0            ; 1=YES/0=NO
  67. ROSVersion    = 1            ; required ros.library version
  68.  
  69. *------------------------------------------------------------------------------
  70. ; CPU and chipset options, uncomment if you need it
  71.  
  72. ;_CPUType    = AFB_68020        ; Set the CPU type you need
  73. ;_ChipSetType    = ROSCSB_AGA        ; Set the chipset (ECS or AGA) you need
  74.  
  75. _CacheBits    = CACRF_EnableI!CACRF_IBE!CACRF_EnableD!CACRF_DBE!CACRF_WriteAllocate!CACRF_CopyBack
  76. _CacheMask    = CACRF_EnableI!CACRF_IBE!CACRF_EnableD!CACRF_DBE!CACRF_WriteAllocate!CACRF_CopyBack
  77.  
  78. *------------------------------------------------------------------------------
  79. ; The Player 6.1A options
  80.  
  81. ;use        = -1        ; The Usecode, uncomment to use P61A player
  82.  
  83.     IFD     use
  84. opt020        = 0        ; 0 = MC680x0 code, 1 = MC68020+ or better
  85. ;start        = 6        ; Starting position, uncomment if you need
  86. fade        = 0        ; 0 = normal, 1 = use master volume
  87. CIA        = 1        ; 0 = disabled, 1 = enabled
  88. channels    = 4        ; amount of channels to be played
  89. jump        = 1        ; 0 = do NOT include position jump code
  90.     ENDC
  91.  
  92. *------------------------------------------------------------------------------
  93.  
  94.     printt    ""
  95.     printt    "Code options used:"
  96.     printt    "------------------"
  97.  
  98.     IFD    _CPUType
  99.     IF    _CPUType=AFB_68010
  100.     printt    "CPU: 68000"
  101.     ELSE
  102.     IF    _CPUType=AFB_68020
  103.     printt    "CPU: 68020"
  104.     ELSE
  105.     IF    _CPUType=AFB_68030
  106.     printt    "CPU: 68030"
  107.     ELSE
  108.     IF    _CPUType=AFB_68040
  109.     printt    "CPU: 68040"
  110.     ELSE
  111.     IF    _CPUType=AFB_68060
  112.     printt    "CPU: 68060"
  113.     ENDC
  114.     ENDC
  115.     ENDC
  116.     ENDC
  117.     ENDC
  118.     ELSE
  119.     printt    "CPU: no check"
  120.     ENDC
  121.  
  122.     IFD    _ChipSetType
  123.     IF    _ChipSetType=ROSCSB_AGA
  124.     printt    "ChipSet: AGA"
  125.     ELSE
  126.     printt    "ChipSet: ECS"
  127.     ENDC
  128.     ELSE
  129.     printt    "ChipSet: no check"
  130.     ENDC
  131.  
  132.     printt    ""
  133.  
  134. *------------------------------------------------------------------------------
  135. ;Screen constants
  136.  
  137. ScrWidth    = 40
  138. ScrHeight    = 256
  139. Scr        = ScrWidth*ScrHeight    ; Size of the screen
  140. Bpl        = 1            ; Number of BitPlanes
  141.  
  142.  
  143. *------------------------------------------------------------------------------
  144. ; The code
  145.  
  146.     SECTION    Code,CODE
  147.  
  148.     IFEQ SourceTest
  149.     INCLUDE    misc/easystart.i    ; Then the proggy runs from Workbench
  150.     ENDC
  151.     
  152. PrgStart:
  153.     moveq    #0,d0
  154.     lea    _IntName(pc),a1
  155.     CALLEXEC OpenLibrary
  156.     move.l    d0,_IntuitionBase
  157.     beq.w    .end
  158.  
  159.     moveq    #ROSVersion,d0
  160.     lea    _ROSName(pc),a1
  161.     jsr    _LVOOpenLibrary(a6)
  162.     move.l    d0,_ROSBase
  163.     bne.b    .libok
  164.  
  165.     moveq    #0,d0
  166.     moveq    #0,d1
  167.     move.w    #20*8+52,d2        ; req width
  168.     move.w    #1*10+50,d3        ; req height
  169.     sub.l    a0,a0
  170.     sub.l    a2,a2
  171.     lea    .body(pc),a1
  172.     lea    .neggad(pc),a3
  173.     move.l    _IntuitionBase(pc),a6
  174.     jsr    _LVOAutoRequest(a6)    ; error requester
  175.     bra.w    .closeint
  176.  
  177. .neggad    dc.b    0            ; FrontPen
  178.     dc.b    1            ; BackPen
  179.     dc.b    0            ; DrawMode
  180.     dc.b    0            ; Fill
  181.     dc.w    6            ; LeftEdge
  182.     dc.w    3            ; TopEdge
  183.     dc.l    0            ; No special font
  184.     dc.l    .gadtxt            ; Pointer to text
  185.     dc.l    0            ; No more text
  186.  
  187. .body    dc.b    0            ; FrontPen
  188.     dc.b    1            ; BackPen
  189.     dc.b    0            ; DrawMode
  190.     dc.b    0            ; Fill
  191.     dc.w    16            ; LeftEdge
  192.     dc.w    10            ; TopEdge
  193.     dc.l    0            ; No special font
  194.     dc.l    .txt1            ; Pointer to text
  195.     dc.l    0            ; No more text
  196.  
  197. .gadtxt    dc.b    "Abort",0
  198. .txt1    dc.b    "Can't open ros.library V",ROSVersion+"0",0
  199.     even
  200.  
  201.  
  202. *--------------------------------------
  203. .libok    move.l    _ROSBase(pc),a6
  204.  
  205.  
  206. *--------------------------------------
  207. ; set Caches
  208.  
  209.     move.l    #AllCaches,d0        ; cachebits
  210.     move.l    #AllCaches,d1        ; cachemask
  211.     jsr    _LVOROSSetCache(a6)
  212.  
  213. *--------------------------------------
  214. ; Hardware Check
  215.  
  216.     IFD    _CPUType
  217.     move.w    #_CPUType,d0
  218.     jsr    _LVOROSCPUCheck(a6)
  219.     tst.w    d0
  220.     beq.w    .closeROS
  221.     ENDC
  222.  
  223.     IFD    _ChipSetType
  224.     move.w    #_ChipSetType,d0
  225.     jsr    _LVOROSChipsetCheck(a6)    
  226.     tst.w    d0
  227.     beq.w    .closeROS
  228.     ENDC
  229.  
  230.     IFD    use
  231.     jsr    _LVOROSAllocAudio(a6)
  232.     tst.w    d0
  233.     beq.w    .closeROS
  234.     ENDC
  235.  
  236. *--------------------------------------
  237. ; Some initializings
  238.  
  239.     move.l    #Screen1,d0        ; Set plane pointers of Screen1
  240.     lea    CopBpl,a0
  241.     move.w    #Bpl-1,d1        ; # of planes
  242. .Loop1    move.w    d0,6(a0)
  243.     swap    d0
  244.     move.w    d0,2(a0)
  245.     swap    d0
  246.     addq.l    #8,a0
  247.     add.l    #Scr,d0
  248.     dbf    d1,.Loop1
  249.  
  250. *--------------------------------------
  251. ; set Playerinterrupt
  252.  
  253.     IFD    use
  254.     lea    P61_lev6server(pc),a0
  255.  
  256.     moveq    #INTB_CIABTIMA,d0
  257.     jsr    _LVOROSSetIntVec(a6)
  258.     tst.w    d0
  259.     beq.b    .timb
  260.     move.w    #INTF_CIABTIMA,d0
  261.     moveq    #0,d1            ; indicate timer a usage
  262.     bra.b    .ciaok
  263.  
  264. .timb    moveq    #INTB_CIABTIMB,d0
  265.     jsr    _LVOROSSetIntVec(a6)
  266.     tst.w    d0
  267.     beq.w    .freeaudio
  268.     move.w    #INTF_CIABTIMB,d0
  269.     moveq    #1,d1            ; indicate timer b usage
  270.  
  271. .ciaok    move.w    d0,_CiaIntFlag
  272.     move.w    d1,_CiaTimer
  273.     ENDC
  274.  
  275. *--------------------------------------
  276.  
  277.     lea    ExitHandler(pc),a0
  278.     jsr    _LVOROSSetExitHandler(a6)
  279.  
  280.  
  281.     moveq    #KILLF_DEATHMODE,d0
  282. ;    moveq    #KILLF_SYSMODE,d0
  283.     jsr    _LVOROSKillSystem(a6)
  284.     tst.w    d0
  285.     beq.w    .afterawake
  286.  
  287. *--------------------------------------
  288. ; PlayerInit
  289.  
  290.     IFD    use
  291.     IFD    Smpl
  292.     lea    Smpl,a1            ; Samples
  293.     ELSE
  294.     sub.l    a1,a1
  295.     ENDC
  296.  
  297.     IFD    SmpBuf
  298.     lea    SmpBuf,a2        ; Sample buffer
  299.     ENDC
  300.  
  301.     lea    Song,a0            ; Module
  302.     moveq    #0,d0            ; Auto Detect
  303.     move.w    _CiaTimer(pc),d1    ; indicate timer usage
  304.     bsr.w    P61_motuuli+P61_InitOffset
  305.     ENDC
  306.     
  307. *--------------------------------------
  308.  
  309.     jsr    _LVOROSWaitVBlank(a6)
  310.     lea    CopList1,a0
  311.     moveq    #COPF_COPPER1!COPF_STROBE,d0
  312.     jsr    _LVOROSSetCopper(a6)
  313.     move.w    #DMAF_SETCLR!DMAF_MASTER!DMAF_RASTER!DMAF_COPPER,d0
  314.     jsr    _LVOROSSetDMA(a6)
  315.  
  316.     lea    Inter(pc),a0
  317.     moveq    #INTB_VERTB,d0
  318.     jsr    _LVOROSSetIntVec(a6)
  319.  
  320.     move.w    #INTF_SETCLR!INTF_INTEN!INTF_VERTB,d0
  321.     IFD    use
  322.     or.w    _CiaIntFlag(pc),d0    ; start P61 int
  323.     ENDC
  324.     jsr    _LVOROSSetInt(a6)
  325.  
  326. *--------------------------------------
  327. ; Init-Routines
  328.  
  329. .Inits
  330.  
  331.  
  332. *--------------------------------------
  333. ; Main-Program
  334.  
  335. .MainLoop    
  336. ;    jsr    _LVOROSWaitVBlank(a6)
  337.  
  338.  
  339.  
  340. ;.lp    btst    #6,$bfe001
  341. ;    bne.b    .1
  342.  
  343.  
  344.  
  345. .tstend    move.b    endflag(pc),d0
  346.     beq.b    .MainLoop
  347.  
  348. *--------------------------------------
  349.  
  350.     jsr    _LVOROSWaitVBlank(a6)
  351.     move.w    #DMAF_MASTER!DMAF_RASTER!DMAF_COPPER,d0 ; clear dma
  352.     jsr    _LVOROSSetDMA(a6)
  353.     move.w    #INTF_VERTB,d0        ; clear int
  354.     IFD    use
  355.     or.w    _CiaIntFlag(pc),d0    ; stop P61 int
  356.     ENDC
  357.     jsr    _LVOROSSetInt(a6)
  358.  
  359.     IFD    use
  360.     bsr.w    P61_motuuli+P61_EndOffset
  361.     ENDC
  362.  
  363.     jsr    _LVOROSAwakeSystem(a6)
  364. .afterawake
  365.  
  366.  
  367. .freeaudio
  368.     IFD    use
  369.     jsr    _LVOROSFreeAudio(a6)
  370.     ENDC
  371.  
  372. .closeROS
  373.     move.l    _ROSBase(pc),a1
  374.     CALLEXEC CloseLibrary
  375.  
  376. .closeint
  377.     move.l    _IntuitionBase(pc),a1
  378.     CALLEXEC CloseLibrary
  379.  
  380. .end    moveq    #0,d0
  381.     rts
  382.  
  383. *--------------------------------------
  384.  
  385. _ROSBase    dc.l    0
  386. _IntuitionBase    dc.l    0
  387.  
  388.     IFD    use
  389. _CiaTimer    dc.w    0        ; P61 timer flags
  390. _CiaIntFlag    dc.w    0
  391.     ENDC
  392.  
  393. _ROSName    ROSNAME
  394. _IntName    INTNAME
  395.  
  396. endflag        dc.b    0
  397.         even
  398.  
  399. *--------------------------------------
  400.  
  401. ExitHandler:
  402.     move.b    #1,endflag
  403.     rts
  404.  
  405.  
  406. *------------------------------------------------------------------------------
  407. ; Players
  408.  
  409.     IFD    use
  410.     INCLUDE    Player/player610.2_ROS.s ; The Player 6.1a
  411.     ENDC
  412.  
  413. *------------------------------------------------------------------------------
  414.  
  415. Inter:                    ; Level 3 Interrupt-Routine
  416. ; The routines every interrupt
  417.  
  418.  
  419.     rts
  420.  
  421. *------------------------------------------------------------------------------
  422.  
  423.  
  424.  
  425.  
  426.  
  427. *------------------------------------------------------------------------------
  428. ; Copper area
  429.  
  430.     SECTION    Copper1,DATA_C
  431.  
  432. CopList1:
  433. CopBpl    dc.w    $00e0,0000        ; bpl-pointers
  434.     dc.w    $00e2,0000
  435.     dc.w    $00e4,0000
  436.     dc.w    $00e6,0000
  437.     dc.w    $00e8,0000
  438.     dc.w    $00ea,0000
  439.     dc.w    $00ec,0000
  440.     dc.w    $00ee,0000
  441.     dc.w    $00f0,0000
  442.     dc.w    $00f2,0000
  443.     dc.w    $00f4,0000
  444.     dc.w    $00f6,0000
  445.     dc.w    $00f8,0000
  446.     dc.w    $00fa,0000
  447.     dc.w    $00fc,0000
  448.     dc.w    $00fe,0000
  449.     dc.w    $0100,Bpl<<12!$200    ; bit-plane control reg.
  450.     dc.w    $0102,$0000        ; hor-scroll
  451.     dc.w    $0104,$0010        ; sprite/gfx priority
  452.     dc.w    $01fc,$0000        ; fetch mode
  453.     dc.w    $0108,$0000        ; modolu (odd)
  454.     dc.w    $010a,$0000        ; modolu (even)
  455.     dc.w    $008e,$2c81        ; screen size
  456.     dc.w    $0090,$2cc1        ; screen size
  457.     dc.w    $0092,$0038        ; h-start
  458.     dc.w    $0094,$00d0        ; h-stop
  459. ; end of initializing, and now the user-copper-data
  460.     dc.w    $0180,$0000
  461.     dc.l    $fffffffe        ; end of copperlist
  462.  
  463.  
  464. *------------------------------------------------------------------------------
  465. ; Screen area
  466.  
  467.     SECTION    Screen1,BSS_C
  468.  
  469. Screen1    DS.B    Scr*Bpl            ; Area for Screen1
  470.  
  471.  
  472. *------------------------------------------------------------------------------
  473. ; Music area
  474.  
  475.     IFD    use
  476.  
  477.     SECTION    Music1,DATA_C    ; Chipmem for entire module or for samples
  478.                 ; Uncomment if you use separate samples
  479. ;Smpl    INCBIN    st-00:modules/p61a/smp.art
  480.  
  481.  
  482.     IFD    Smpl
  483.     SECTION    Music2,DATA    ; If separate samples, we use fast mem for song
  484.     ENDC
  485. Song    INCBIN    st-00:modules/p61a/p61.art
  486.  
  487.  
  488.     SECTION    Music3,BSS_C
  489. ;SmpBuf    DS.B    120000        ; Uncomment if you have packed samples
  490.                 ; and insert sample buffer length
  491.     ENDC
  492.  
  493. *------------------------------------------------------------------------------
  494.  
  495.     IFEQ SourceTest
  496.     printt    ""
  497.     printt    ""
  498.     printt    "Attention Workbench-Startup enabled"
  499.     printt    ""
  500.     AUTO    WO\
  501.     ENDC
  502.  
  503. *------------------------------------------------------------------------------
  504. End:                    ; The end of all shit
  505.  
  506.